<?php
$login = array('id' => 'login', 'name' => 'login', 'value' => set_value('login'), 'size' => 30, 'maxlength' => 80);
$password = array('id' => 'password', 'name' => 'password', 'size' => 30);
$remember = array('id' => 'remember', 'name' => 'remember', 'value' => 1, 'checked' => set_value('remember'));
$captcha = array('id' => 'captcha', 'name' => 'captcha', 'maxlength' => 8);
$submit = array('class' => 'btn btn-success', 'name' => 'submit', 'value' => lang('auth_login'));
$login_label = ($login_by_username and $login_by_email) ? 'auth_email_or_username' : ($login_by_username ? 'auth_username' : 'auth_email');

echo form_open($this->uri->uri_string());
?>

<div class="page-header">
    <h3><?php echo lang('auth_login'); ?></h3>
</div>

<p>
    <span class="form-inline">
        <?php
        echo
        lang($login_label, $login['id']).form_input($login).
        form_error($login['name'], '<span class="alert">', '</span>');
        if(isset($errors[$login['name']]))
            echo '<span class="alert">'.$errors[$login['name']].'</span>';
        ?>
    </span>
    <span class="form-inline">
        <?php
        echo
        lang('auth_password', $password['id']).form_password($password).
        form_error($password['name'], '<span class="alert">', '</span>');
        if(isset($errors[$password['name']]))
            echo '<span class="alert">'.$errors[$password['name']].'</span>';
        ?>
    </span>
</p>

<?php
if($show_captcha) {
    if($use_recaptcha):
    ?>

    <div id="recaptcha" class="clearfix">
        <p id="recaptcha_image"></p>
        <p id="recaptcha_other">
            <a href="javascript:Recaptcha.reload()"><?php echo lang('auth_get_another_captcha'); ?></a><br />
            <a class="recaptcha_only_if_image" href="javascript:Recaptcha.switch_type('audio')"><?php echo lang('auth_get_audio_captcha'); ?></a>
            <a class="recaptcha_only_if_audio" href="javascript:Recaptcha.switch_type('image')"><?php echo lang('auth_get_image_captcha'); ?></a>
        </p>
    </div>

    <p>
        <span class="form-inline">
            <?php
            echo
            form_label(lang('auth_enter_words'), 'recaptcha_response_field', array('class' => 'recaptcha_only_if_image')).
            form_label(lang('auth_enter_numbers'), 'recaptcha_response_field', array('class' => 'recaptcha_only_if_audio')).
            form_input(array('id' => 'recaptcha_response_field', 'name' => 'recaptcha_response_field'));
            ?>
        </span>
        <?php
        echo
        form_error('recaptcha_response_field', '<span class="form-inline alert">', '</span>').
        $recaptcha_html;
        ?>
    </p>

    <?php
    else:
    ?>

    <p><?php echo lang('auth_enter_captcha_code'); ?></p>
    <p><?php echo $captcha_html; ?></p>
    <p>
        <span class="form-inline"><?php echo lang('auth_confirmation_code', $captcha['id']).form_input($captcha); ?></span>
        <span class="form-inline alert"><?php echo form_error($captcha['name'], '<span class="error">', '</span>'); ?></span>
    </p>

    <?php
    endif;
}
?>

<p>
    <span id="remember_me"><?php echo form_checkbox($remember).' '.lang('auth_remember_me', $remember['id']); ?></span>
    <span id="forgot_password">
        <?php
        echo anchor('/auth/forgot_password/', lang('auth_forgot_password'));
        if($this->config->item('allow_registration', 'tank_auth'))
            echo nbs(4).anchor('/auth/register/', lang('auth_register'));
        ?>
    </span>
</p>

<p class="form-actions"><?php echo form_submit($submit); ?></p>

<?php form_close(); ?>